Skip to content

Conversation

@fern-api
Copy link
Contributor

@fern-api fern-api bot commented Dec 9, 2025

Changes

This PR updates the Management API code with several improvements:

Authentication & Client Options:

  • Refactored internal authentication to use AuthProvider abstraction pattern
  • Added logging option to client configuration for debugging
  • These are internal implementation changes - the wrapper and user-facing API remain unchanged

Error Handling:

  • Enhanced error classes with proper prototype chain using new.target.prototype
  • Added stack trace capture with Error.captureStackTrace for better debugging
  • Centralized non-status-code error handling via handleNonStatusCodeError

Pagination:

  • Fixed pagination logic with Math.floor() for page size calculations
  • Simplified page offset increment logic

Internal Refactoring:

  • Renamed internal client classes with Client suffix (e.g., ActionsActionsClient)
  • Simplified header merging by replacing mergeOnlyDefinedHeaders with mergeHeaders
  • Updated Jest configuration with proper TypeScript config paths and setup files

Other:

  • SDK version bumped from 5.0.0 to 5.1.0
  • Various dependency updates

Note: All changes are internal implementation details. The ManagementClient wrapper and user-facing API remain unchanged.


Logging Examples

The new logging option allows you to configure debug logging for API requests:

Enable debug logging with default console logger:

import { ManagementClient } from 'auth0';

const client = new ManagementClient({
  domain: 'your-tenant.auth0.com',
  clientId: 'your-client-id',
  clientSecret: 'your-client-secret',
  logging: {
    level: 'debug',  // 'debug' | 'info' | 'warn' | 'error'
    silent: false    // Set to false to enable logging output
  }
});

Use a custom logger implementation:

import { ManagementClient } from 'auth0';

const customLogger = {
  debug: (msg, ...args) => myLogger.debug(msg, args),
  info: (msg, ...args) => myLogger.info(msg, args),
  warn: (msg, ...args) => myLogger.warn(msg, args),
  error: (msg, ...args) => myLogger.error(msg, args),
};

const client = new ManagementClient({
  domain: 'your-tenant.auth0.com',
  clientId: 'your-client-id',
  clientSecret: 'your-client-secret',
  logging: {
    level: 'info',
    logger: customLogger,
    silent: false
  }
});

References

  • Automated SDK regeneration from API definition updates

Testing

  • This change adds unit test coverage
  • This change adds integration test coverage

Existing tests updated to work with the new configuration patterns (e.g., maxRetries: 0 added to test clients).

Checklist

@fern-api fern-api bot requested a review from a team as a code owner December 9, 2025 08:56
@codecov
Copy link

codecov bot commented Dec 9, 2025

Codecov Report

❌ Patch coverage is 85.93394% with 247 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.20%. Comparing base (45a04c7) to head (eba1d94).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...actors/resources/pushNotification/client/Client.ts 78.57% 9 Missing ⚠️
...resources/factors/resources/phone/client/Client.ts 78.94% 8 Missing ⚠️
.../management/api/resources/actions/client/Client.ts 84.44% 7 Missing ⚠️
...sources/phone/resources/templates/client/Client.ts 79.41% 7 Missing ⚠️
...ement/api/resources/customDomains/client/Client.ts 79.41% 7 Missing ⚠️
...sources/keys/resources/encryption/client/Client.ts 80.55% 7 Missing ⚠️
...sources/phone/resources/providers/client/Client.ts 80.00% 6 Missing ⚠️
.../management/api/resources/clients/client/Client.ts 84.21% 6 Missing ⚠️
...agement/api/resources/connections/client/Client.ts 85.36% 6 Missing ⚠️
...gement/api/resources/eventStreams/client/Client.ts 83.33% 6 Missing ⚠️
... and 57 more
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #1274       +/-   ##
===========================================
+ Coverage   78.20%   89.20%   +10.99%     
===========================================
  Files         356      362        +6     
  Lines       17746    16216     -1530     
  Branches     9555     8174     -1381     
===========================================
+ Hits        13878    14465      +587     
+ Misses       3868     1751     -2117     
Flag Coverage Δ
alltests 89.20% <85.93%> (+10.99%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@developerkunal developerkunal changed the title 🌿 Fern Regeneration -- December 9, 2025 feat: Fern SDK regeneration with auth provider refactoring and improved error handling Dec 9, 2025
@developerkunal developerkunal changed the title feat: Fern SDK regeneration with auth provider refactoring and improved error handling feat: Auth provider refactoring, improved error handling, and SDK enhancements Dec 9, 2025
@developerkunal developerkunal merged commit 2103848 into master Dec 10, 2025
10 checks passed
@developerkunal developerkunal deleted the fern-bot/2025-12-09T08-56Z branch December 10, 2025 08:30
@developerkunal developerkunal mentioned this pull request Dec 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants